package T13_return_value_Callable;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
public class T12_return_value_Callable {    
    public static void main(String[] args) throws ExecutionException, InterruptedException {    
        ExecutorService pool = Executors.newFixedThreadPool(2);    
        Callable<String> c1 = new MyCallable("A");    
        Callable<String> c2 = new MyCallable("B");   
        
        Future<String> f1 = pool.submit(c1);    
        Future<String> f2 = pool.submit(c2);   
        
        System.out.println(">>>"+f1.get().toString());    
        System.out.println(">>>"+f2.get().toString());    
        pool.shutdown();    
    }    
}    
class MyCallable implements Callable<String>{    
	private String oid;    
	MyCallable(String oid) {    
		this.oid = oid;    
	}    
	@Override    
	public String call() throws Exception {   
		for(int i = 0; i<10;i++){
			System.out.println(oid+"循环次数"+i);    
		}
        return oid+"任务返回的内容";    
	}    
}  
